var windWidth = wx.getSystemInfoSync().windowWidth;//这里获取下设备的屏幕宽度
 
Component({
 
  /**
   * 组件的属性列表
   */
  properties: {
    //画布的宽度 默认占屏幕宽度的0.4倍
    wd: {
      type: Number,
      value: 10
    },
  },
  /**
   * 组件的初始数据
   */
  data: {

  },
  /**
   * 组件的方法列表
   */
  methods: {
    drawCanvasRing() {
      //canvas 2d
      const query = wx.createSelectorQuery().in(this);
      query.select('#myCanvas')
        .fields({ node: true , size: true})
        .exec(this.init.bind(this))
    },
 
    init(res){
      const canvas = res[0].node
      const ctx = canvas.getContext('2d');
      var wd = this.data.wd;
     // const dpr = wx.getSystemInfoSync().pixelRatio;
      // const width = canvas.width/2-(wd/2); //起点 
      // const height = canvas.height/2 -(wd/4);  //起点
      // ctx.clearRect(width,height,wd,wd);
      // ctx.moveTo(width, height);
      // ctx.lineTo(width+wd, height);
      // ctx.moveTo(width, height+(wd/4));
      // ctx.lineTo(width+wd, height+(wd/4));
      // ctx.moveTo(width, height);
      // ctx.lineTo(width, height+(wd/2));
      // ctx.moveTo(width, height+(wd/2));
      // ctx.lineTo(width+wd, height+(wd/2));
      const width = canvas.width; //起点 
      const height = canvas.height;  //起点
      console.log(width+"  "+height)
      ctx.moveTo(20, 20);
      ctx.lineTo(width-40,20);
      ctx.moveTo(20, height/2);
      ctx.lineTo(width-40,height/2);
      ctx.moveTo(20, height-20);
      ctx.lineTo(width-40,height-20);
      ctx.moveTo(20,20);
      ctx.lineTo(20,height-20);
      ctx.stroke()
      
    }
  }
})